package com.changli03._list.exer2;

import java.util.*;

public class Exer02 {
    public static void main(String[] args) {
        List list = new ArrayList();
        Random rand = new Random();
        for (int i = 0; i < 30; i++) {
            list.add((char) (rand.nextInt(26)  + 97)+"");
//            list.add(x);
        }
        System.out.println(list);
        int aCount = listTest(list,"a");
        int bCount = listTest(list,"b");
        int cCount = listTest(list,"c");
        int xCount = listTest(list,"x");
        System.out.println("a:"+aCount);
        System.out.println("b:"+bCount);
        System.out.println("c:"+cCount);
        System.out.println("x:"+xCount);

    }

    public static int listTest (Collection list,String s){
        int  count = 0;
        for(Object o : list){
            if(o.equals(s)){
                count++;
            }
        }
        return count;
    }
}

